package com.unbox.admin.controller;

import com.unbox.admin.entity.Apps;
import com.unbox.admin.fegin.AppsFegin;
import com.unbox.admin.service.IAppsService;
import com.unbox.common.response.UnboxResponse;
import com.unbox.common.table.UnBoxPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * <p>
 * < 应用管理业务Controller
 * </p>
 *
 * @author 王振宇
 * @since 2021-05-13
 */
@Api(tags = " 应用管理管理api")
@RestController
public class AppsController implements AppsFegin {

    @Autowired
    IAppsService appsService;

    /**
     * 分页查询
     * @param apps
     * @return
     */
    @ApiOperation(value = "分页查询列表")
    @Override
    public UnboxResponse<UnBoxPage> getPageList(Apps apps, Integer pageNo, Integer pageSize) {
        UnBoxPage page = appsService.getPageList(apps,pageNo, pageSize);
        return new UnboxResponse<>(page);
    }

    /**
     * 查询列表
     *
     * @param apps
     * @return
     */
    @Override
    public UnboxResponse<List<Apps>> getList(Apps apps) {
        List<Apps> datas = appsService.getList(apps);
        return new UnboxResponse<>(datas);
    }

    /**
     * 详情
     * @param apps
     * @return
     */
    @ApiOperation(value = "查询明细")
    @Override
    public UnboxResponse<Apps> info(Apps apps) {
        Apps appsVo = appsService.get(apps);
        return new UnboxResponse<>(appsVo);
    }

    /**
     * 通过id数据查询数据
     * @param ids
     * @return
     */
    @ApiOperation(value = "通过ids进行in查询")
    @Override
    public UnboxResponse<List<Apps>> idsAppss(List<Integer> ids) {
        List<Apps> appss = appsService.getIdsList(ids);
        return new UnboxResponse<>(appss);
    }

    /**
     * 保存数据
     * @param apps
     * @return
     */
    @ApiOperation(value = "保存数据")
    @Override
    public UnboxResponse<Boolean> save(Apps apps) {
        Boolean flg = appsService.save(apps);
        return new UnboxResponse<>(flg);
    }

    /**
     * 批量添加
     * @param appss
     * @return
     */
    @ApiOperation(value = "批量保存数据")
    @Override
    public UnboxResponse<Boolean> batchSave(List<Apps> appss) {
        Boolean flg = appsService.saveBatch(appss);
        return new UnboxResponse<>(flg);
    }

    /**
     * 修改数据
     * @param apps
     * @return
     */
    @ApiOperation(value = "修改数据")
    @Override
    public UnboxResponse<Boolean> update(Apps apps) {
        Boolean flg = appsService.update(apps);
        return new UnboxResponse<>(flg);
    }

    /**
     * 批量修改
     * @param appss
     * @return
     */
    @ApiOperation(value = "批量修改数据")
    @Override
    public UnboxResponse<Boolean> batchUpdate(List<Apps> appss) {
        Boolean flg = appsService.updateBatchById(appss);
        return new UnboxResponse<>(flg);
    }

    /**
     * 删除数据
     * @param apps
     * @return
     */
    @ApiOperation(value = "删除数据")
    @Override
    public UnboxResponse<Boolean> delete(Apps apps) {
        Boolean flg = appsService.remove(apps);
        return new UnboxResponse<>(flg);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @ApiOperation(value = "批量删除")
    @Override
    public UnboxResponse<Boolean> deleteBatch(List<Integer> ids) {
        Boolean flg = appsService.removeByIds(ids);
        return new UnboxResponse<>(flg);
    }
}

